package com.dangf.hzapp.adapter;

import java.util.List;

import com.dangf.hzapp.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 菜单适配器
 * @author 韦海生
 * @date 2014年8月5日
 */
public class MenuAdapter extends BaseAdapter {
	private LayoutInflater layoutInflater;
	private String[] list;
	
	
	public MenuAdapter(Context context,String[] list) {
		layoutInflater = LayoutInflater.from(context);
		this.list= list;
	}
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView = layoutInflater.inflate(R.layout.fragment_menu_item, null);
		}
		
		TextView menu_text = (TextView) convertView.findViewById(R.id.menu_text);
		
		menu_text.setText(list[position]);	//设置标题
		
		return convertView;
	}

}
